home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
pi-5ways.zip
/
PI3.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-15
|
1KB
|
40 lines
/**************************************************************************/
/* Calculate π by Leonhard Euler approximation */
/* π ≈ √ { 6 ( 1/1 + 1/4 + 1/9 + 1/16 + 1/25 ... + 1/(n+1)**2 ...) } */
/* */
/* */
/* Mendel Cooper */
/* 3138 Foster Ave. */
/* Baltimore, MD 21224 */
/* */
/* 06/91 */
/* Source code placed in the public domain */
/**************************************************************************/
/*may need #include <math.h> */
#define MAX 5000
main()
{
double sqrt(),intermediate_result = 0,Pi;
register int k;
for (k = 0; k <= MAX; k++)
{
intermediate_result += 1.0 / ( (k + 1.0) * (k + 1.0) );
Pi = sqrt( 6.0 * intermediate_result);
printf("Term #%5d -------> π ≈ %f \n",k,Pi); }
}